<#include "../global/global.ftl" encoding="UTF-8" />
<#assign assign_dao="${dao.name?uncap_first}">
<#lt/>
<#lt/>
<#lt/>
package ${service.implement.package};

import java.util.List;
import java.util.Map;

<#if table.primary_count == 1>
import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;
<#else>import org.springframework.stereotype.Service;
</#if>

import com.zorn.core.spring.mvc.support.ServiceSupport;
import ${service.interface.namespace};
import ${dao.namespace};

@Service
public class ${service.implement.name} extends ServiceSupport implements ${service.interface.name} {

	/* Fields
	================================================== */
	private ${dao.name} ${assign_dao};

	/* Methods
	================================================== */
	public List<Map<String, Object>> ${(service.interface.method.query.name)!"query"}(Map<String, Object> params) {
		return setQueryResult(${assign_dao}.query(params), ${assign_dao}.count(params));
	}

	public int ${(service.interface.method.count.name)!"count"}(Map<String, Object> params) {
		return setCountResult(${assign_dao}.${(dao.method.count.name)!"count"}(params));
	}

	public int ${(service.interface.method.insert.name)!"insert"}(Map<String, Object> params) {
		return setInsertResult(${assign_dao}.insert(params), <#if table.primary_count == 1>MapUtils.getIntValue(params, "${table.primary}")<#else>0</#if>);
	}

	public int ${(service.interface.method.update.name)!"update"}(Map<String, Object> params) {
		return setUpdateResult(${assign_dao}.${(dao.method.update.name)!"update"}(params));
	}

	public int ${(service.interface.method.delete.name)!"delete"}(Map<String, Object> params) {
		return setDeleteResult(${assign_dao}.${(dao.method.delete.name)!"delete"}(params));
	}

	/* Getters & Setters
	================================================== */
	public void set${dao.name}(${dao.name} ${assign_dao}) {
		this.${assign_dao} = ${assign_dao};
	}

}